package com.booth.base.render;

import java.io.IOException;

import javax.servlet.http.HttpSession;

import com.booth.base.utils.ValidateCode;
import com.jfinal.render.Render;
/***
 * 生成校验码图片渲染器
 * @TypeName：JCaptchaRender
 * @description：
 * @author：Administrator
 */
public class JCaptchaRender extends Render
{
  public void render()
  {
    this.response.setHeader("Cache-Control", "no-store");
    this.response.setHeader("Pragma", "no-cache");
    this.response.setDateHeader("Expires", 0L);
    this.response.setContentType("image/jpeg");
    HttpSession session = this.request.getSession(true);
    ValidateCode vCode = new ValidateCode(120, 40, 4, 0);
    session.setAttribute("code", vCode.getCode());
    try {
      vCode.write(this.response.getOutputStream());
    }
    catch (IOException e1) {
      e1.printStackTrace();
    }
  }
}